﻿using System;
using System.Collections;
using Wintellect.PowerCollections;

namespace PriorityQueue
{
    class PriorityQueue<T> : IEnumerable
        where T : IComparable<T>
    {
        private OrderedBag<T> bag;

        public PriorityQueue()
        {
            this.bag = new OrderedBag<T>();
        }

        public void Enqueue(T item)
        {
            bag.Add(item);
        }

        public T Dequeue()
        {
            return bag.RemoveFirst();
        }

        public IEnumerator GetEnumerator()
        {
            var enumerator = bag.GetEnumerator();
            return enumerator;
        }
    }
}
